home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / ralloc.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  7KB  |  220 lines

  1. /*
  2.  
  3.                      RCB_ALLOCATED
  4.  
  5.      Perfoms further processing of the ALLOCATE request.
  6.      It is invoked when PS receives an RCB_ALLOCATED
  7.      recod  from RM.
  8.  
  9.   CopyRight 1995. Nicholas Poljakov all rights reserved.
  10.  
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include <malloc.h>
  15. #include <alloc.h>
  16. #include <tcb.h>
  17. #include <mode.h>
  18. #include <lucb.h>
  19. #include <arcb.h>
  20. #include <state1.h>
  21. #include <rcballoc.h>
  22. #include <rcb.h>
  23. #include <fmh5.h>
  24. #include <string.h>
  25. int sk_r_wt(void *);
  26. int SendBlock(void *, void *);
  27. int setrc(void *, void *);
  28. int sendhsf(void *);
  29. int sendhs(void *);
  30. int sendbm(void *, void *);
  31. int sendat(void *);
  32. int rtsend(void *);
  33. unsigned long rmfmh5(void *, void *);
  34. int recwait(void *);
  35. int rcvru(void *, void *);
  36. int rcvhs(void *, void *, void *, void *);
  37. int psrm(int, void *, void *);
  38. int ps_conv(int, void *);
  39. int proterr(void *, unsigned long);
  40. int preptrcv(void *, void *);
  41. int post_rcb(void *);
  42. struct repass *postopen(void *);
  43. int phsrec(void *);
  44. int pfmh5(void *);
  45. int opndst(void *);
  46. int obtsess(void *, unsigned char);
  47. int Lrf_handler(void *);
  48. int get_sess(void *, void *);
  49. int get_attr(void *);
  50. int fsm_error(unsigned char, void *);
  51. int fsm_conv(unsigned char, unsigned char, void *);
  52. int flush (void *);
  53. int dcp(void *);
  54. int dealloc(void *);
  55. int crtp(void *);
  56. int conv(void *);
  57. int chkparm(void *, void *);
  58. int check_end(unsigned int, void *);
  59. struct rqb *call_appl(void *);
  60. int buffmng(unsigned char, void *, void *, void *, unsigned, unsigned char, unsigned);
  61. unsigned long attltck(void *);
  62. unsigned long attacheck(void *);
  63. char *cgetmem(int, int);
  64. int sendhsf(void *);
  65. int opndst(void *);
  66. int alloc_rcb(void *, void *);
  67. int allocate(void *);
  68. int clsdst(void *);
  69.  
  70. ralloc(rcb_alloc, pptr)
  71. struct rcballoc *rcb_alloc;
  72. struct allocate *pptr;
  73. {
  74.    char p1;
  75.    char p2;
  76.    struct rcb *rcb_ptr;
  77.    struct FMH5 *hdr;
  78. /*   struct LUOW1 *lu_ptr; */
  79.    char *header;
  80.    int  tpn_lt;
  81. /*   int  fq_lu;   */
  82.    char *p;
  83.    int  i;
  84.    int  tl;
  85.    unsigned int type;
  86.  
  87. #if OS_TYPE == 1
  88. /*********  Trace facility **********/
  89. unsigned int rtype;   /* type of record */
  90. unsigned int pnum;    /* point number */
  91. char pname[8];        /* name of module */
  92. char *drec;       /* record for dump */
  93. int  lenr;            /* record length */
  94.  
  95. rtype = INPROC;
  96. strcpy(pname, "ralloc");
  97. pnum = 1;
  98. lenr = sizeof(struct rcballoc);
  99. drec = rcb_alloc;
  100. gtf(rtype, pname, pnum, drec, lenr);
  101. /***********************************/
  102. #endif
  103.  
  104.    rcb_ptr = rcb_alloc->rcb_ptr;
  105.  
  106.    switch (rcb_alloc -> rc) {
  107.         case OK :
  108.                 {
  109.                    pptr->prim_rc = OK;
  110.                    p1 = 'S';
  111.                    p2 = Allocate;
  112.                    fsm_conv(p1, p2, rcb_ptr);
  113.                    pptr->conv_id = rcb_ptr->rcb_id;
  114.  
  115.                /*  Initialize allocated RCB */
  116.  
  117.                    rcb_ptr->fill = 0;
  118.                    rcb_ptr->max_length = MAX_LEN;
  119.                    rcb_ptr->locks = SHORT;
  120.                    rcb_ptr->verb_code = Allocate;
  121.                    rcb_ptr->verb_ptr = pptr;
  122.  
  123.                /* Build the FMH-5 (attach) header */
  124.  
  125.                   tpn_lt = pptr -> tp_lt;
  126.                   tl = sizeof(struct FMH5) + tpn_lt;
  127.                   if ((header = calloc(1, tl)) == NULL) {
  128.                      printf("Allocation corrupted. Ralloc/n");
  129.                      return(-1);
  130.                   }
  131.           hdr = (struct FMH5 *)header;
  132.                   hdr -> length = tl;
  133.                   hdr->flag1 = 0;
  134.                   hdr->flag1 = hdr->flag1|FM5TYPE5;
  135.                   hdr->type[0] = 2;
  136.                   hdr->type[1] = 0xff;
  137.                   hdr->flag2 = 0; /*PIP not present */
  138.                   hdr->rsctp = FM5BASIC; /* basic conv.*/
  139.                   hdr->rsrv1 = 0;
  140.                   hdr->flag3 = FM5NONE; /*sync. level */
  141.                   hdr->lntpn = tpn_lt;
  142.                   hdr->lnflp = 3;
  143.                   p = &(*hdr).tpname;
  144.                   for (i = 0; i < tpn_lt; i++) {
  145.                        p[i] = pptr -> tp_name[i];
  146.                   }
  147.                   p[i] = 0x00;  /* Lenth access sec. subfields */
  148.  
  149.               /* Set fully qualified Lu network name
  150.                * Next sets fields LUOW, used only in
  151.                * sync. point level.
  152.  
  153.                   fq_lu = 8 + 2;
  154.                   lu_ptr = &p[i + 1];
  155.                   lu_ptr -> lnfqn = fq_lu - 1;
  156.                   lu_ptr -> lnluw = fq_lu;
  157.                   lu_ptr -> fqnam = 0x04;   SLU identifier (why SLU ?)                  p = &(*lu_ptr).fqnam;
  158.                   p++;
  159.                   for (i = 0; i < fq_lu - 1; i++) {
  160.                        p[i] = pptr -> p_lu_name[i];
  161.                   }
  162.               */
  163.  
  164.               /* Fill buffer pool with FMH-5 and ALLOCATE data */
  165.                   p1 = 'A';
  166.                   type = Fmh;
  167.                   buffmng(p1, hdr, NULL, rcb_ptr, tl, 0, type);
  168.  
  169.                   if (pptr->return_control == WHEN_SESSION_ALLOCATED) {
  170.                     p1 = ATTACH;
  171.                     switch (obtsess(rcb_ptr, p1)) {
  172.                         case 0  : {
  173.                                      pptr -> prim_rc = OK;
  174.                                      break;
  175.                                   }
  176.                         case -1 : {
  177.                                      pptr -> prim_rc = ALLOCATION_FAILURE_NO_RETRY;
  178.                                      break;
  179.                                    }
  180.                         case -2 :  {
  181.                                      pptr -> prim_rc = SYNC_LEVEL_NOT_SUPPORTED;
  182.                                      break;
  183.                                    }
  184.                     }
  185.                   }
  186.                   goto norm_exit;
  187.                 }
  188.         case UNSUCCESSFUL :
  189.                 {
  190.                     pptr->prim_rc = UNSUCCESSFUL;
  191.                     return(0);
  192.                 }
  193.         case SYNC_LEVEL_NOT_SUPPORTED :
  194.                 {
  195.                     p1 = 's';
  196.                     p2 = Allocate;
  197.                     fsm_conv(p1, p2, rcb_ptr);
  198.                /*  Initialize allocated RCB */
  199.  
  200.                    rcb_ptr->fill = 0;
  201.                    rcb_ptr->max_length = MAX_LEN;
  202.                    rcb_ptr->locks = SHORT;
  203.                    rcb_ptr->verb_code = Allocate;
  204.                    rcb_ptr->verb_ptr = pptr;
  205.  
  206.                    p1 = 'r';
  207.                    p2 = ALLOCATION_ERROR_RC;
  208.                    fsm_conv(p1, p2, rcb_ptr);
  209.                    pptr->sec_rc = SYNC_LEVEL_NOT_SUPPORTED_BY_LU;
  210.                    break;
  211.                 }
  212.  
  213.     }
  214.                  pptr->prim_rc = ALLOCATION_ERROR;
  215.                  p1 = 'r';
  216.                  p2 = ALLOCATION_ERROR_RC;
  217.                  fsm_conv(p1, p2, rcb_ptr);
  218.     norm_exit :  return(0);
  219. }
  220.